﻿Restore-SPSite -Identity "http://share" -Path C:\root\portal.bak -force

Backup-SPSite -Identity "http://share" -Path C:\root\portal.bak


$web=Get-SPWeb "http://ecuep.erp.cnpc/"

Import-Csv -path  C:\Solutions\Users\工建\工建-02.csv | ForEach-Object {
    $userName= $_.loginName 
    $name= $_.name
    Write-Host "开始添加用户：$userName $name ..."

    $user = $web.SiteUsers.Add($userName,"",$name,$name)
   
    Set-SPUser -Identity $userName -Web http://ecuep.erp.cnpc -Group '个人工作平台成员' -DisplayName $name

    Write-Host "$name 已添加..."
}

Write-Host "所有用户已添加完毕！"

# Discussion Board
$webUrl = "http://10.30.47.170/Team/";
$web = Get-SPWeb -Identity $webUrl
#$listTemplate = $web.ListTemplates["Discussion Board"] 
$listTemplate = $web.ListTemplates["讨论板"] 
$listNames = "财务共享与控制","资产全生命周期管理","投资项目一体化","物资供应链","安全环保与节能减排","设备全生命周期管理","汽油价值链","新产品开发协同管理"

Foreach ($listName in $listNames) {
	CreateList($web, $listName, $listTemplate);
}

function CreateList($web, $listName, $listTemplate) {
	#$listName = "财务共享与控制";
	$listDescription = "";
	$listId = $web.Lists.Add($listName, $listDescription, $listTemplate);
	$list = $web.Lists[$listId];
	$list.OnQuickLaunch = $true;
	$list.Update();
}